package dao;

import org.apache.log4j.Logger;

/**
 * 打印机程序
 * 面向接口编程，而不是具体的实现类
 */
public class Printer {
    private Ink ink = null;
    private Paper paper = null;
    private Logger logger = Logger.getLogger(Printer.class);

    /**
     * 打印方法
     * @param message 要打印内容
     */
    public void print(String message) {
        //输出标记颜色
        logger.info("使用" + ink.getColor(255, 200, 0) + "颜色打印：\n");
        //逐字符输出到纸张
        for (int i = 0; i < message.length(); i++) {
            paper.putInChar(message.charAt(i));
        }
        //将纸张的内容输出
        logger.info(paper.getContent());
    }

    public void setInk(Ink ink) {
        this.ink = ink;
    }

    public void setPaper(Paper paper) {
        this.paper = paper;
    }
}
